package org.geekbang.time.mathbasicthought.lesson1_binary;

public class ShiftOperation {

    public static void main(String[] args) {
        int number = 53;
        System.out.println(leftShift(number, 1));
        System.out.println(logicRightShift(number, 1));
        System.out.println(arithmeticRightShift(number, 1));

        System.out.println("----------------------");

        int number2 = -53;
        System.out.println(leftShift(number2, 1));
        System.out.println(logicRightShift(number2, 1));
        System.out.println(arithmeticRightShift(number2, 1));
    }

    public static int leftShift(int number, int bit) {
        return number << bit;
    }

    public static int logicRightShift(int number, int bit) {
        return number >>> bit;
    }

    public static int arithmeticRightShift(int number, int bit) {
        return number >> bit;
    }
}
